/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.niclun.projectwebshop.nbp;

import edu.chl.niclun.projectwebshop.nbp.DataBase.Database;
import edu.chl.niclun.projectwebshop.nbp.Entities.Movie;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
 *ControllerBean for the Index.xhtml
 * @author Nume
 */
@ManagedBean(name="ViewIndexControllerBean")
@RequestScoped
public class ViewIndexControllerBean {
   
  @ManagedProperty(value="#{ViewIndexBean}")
  ViewIndexBackingBean indexBean;
 
  
  public ViewIndexControllerBean(){}
  
  //fetch the 3 last added movies to the database 
  @PostConstruct
  public void update(){
      List<Movie> list = Database.getWebshopController().findLastAdded(3);
      indexBean.setMovies(list);
  }

    public ViewIndexBackingBean getIndexBean() {
        return indexBean;
    }

    public void setIndexBean(ViewIndexBackingBean indexBean) {
        this.indexBean = indexBean;
    }

    
   
  
  
}
